package com.csot.ry.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.csot.common.annotation.Log;
import com.csot.common.core.controller.BaseController;
import com.csot.common.core.domain.AjaxResult;
import com.csot.common.enums.BusinessType;
import com.csot.ry.domain.TDcnIp;
import com.csot.ry.service.ITDcnIpService;
import com.csot.common.utils.poi.ExcelUtil;
import com.csot.common.core.page.TableDataInfo;

/**
 * dcn明细ipController
 * 
 * @author csot
 * @date 2023-05-31
 */
@RestController
@RequestMapping("/ipmanagement/dcnip")
public class TDcnIpController extends BaseController
{
    @Autowired
    private ITDcnIpService tDcnIpService;

    /**
     * 查询dcn明细ip列表
     */
    @PreAuthorize("@ss.hasPermi('ipmanagement:dcnip:list')")
    @GetMapping("/list")
    public TableDataInfo list(TDcnIp tDcnIp)
    {
        startPage();
        List<TDcnIp> list = tDcnIpService.selectTDcnIpList(tDcnIp);
        return getDataTable(list);
    }

    /**
     * 导出dcn明细ip列表
     */
    @PreAuthorize("@ss.hasPermi('ipmanagement:dcnip:export')")
    @Log(title = "dcn明细ip", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TDcnIp tDcnIp)
    {
        List<TDcnIp> list = tDcnIpService.selectTDcnIpList(tDcnIp);
        ExcelUtil<TDcnIp> util = new ExcelUtil<TDcnIp>(TDcnIp.class);
        util.exportExcel(response, list, "dcn明细ip数据");
    }

    /**
     * 获取dcn明细ip详细信息
     */
    @PreAuthorize("@ss.hasPermi('ipmanagement:dcnip:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tDcnIpService.selectTDcnIpById(id));
    }

    /**
     * 新增dcn明细ip
     */
    @PreAuthorize("@ss.hasPermi('ipmanagement:dcnip:add')")
    @Log(title = "dcn明细ip", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TDcnIp tDcnIp)
    {
        return toAjax(tDcnIpService.insertTDcnIp(tDcnIp));
    }

    /**
     * 修改dcn明细ip
     */
    @PreAuthorize("@ss.hasPermi('ipmanagement:dcnip:edit')")
    @Log(title = "dcn明细ip", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TDcnIp tDcnIp)
    {
        return toAjax(tDcnIpService.updateTDcnIp(tDcnIp));
    }

    /**
     * 删除dcn明细ip
     */
    @PreAuthorize("@ss.hasPermi('ipmanagement:dcnip:remove')")
    @Log(title = "dcn明细ip", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tDcnIpService.deleteTDcnIpByIds(ids));
    }
}
